
<?php

$_id=$_POST["id"];
$login=$_POST["login"];
$_pass=$_POST["pass"];

$comment=$_POST["comment"];
$lat=$_POST["lat"];
$lng=$_POST["lng"];



$config_sql=file_get_contents("../config_sql.txt");
$arr_config_sql=  explode("!",$config_sql);

$hostname= "$arr_config_sql[1]";


$username = "$arr_config_sql[2]";


$password = "$arr_config_sql[3]";

$db = mysql_connect($hostname, $username, $password) //соединение с базой данных
        or die('connect to database failed');


$table_db=	"$arr_config_sql[4]"; // название таблицы базы
mysql_select_db($table_db) or die('db not found'); //соединение  с базой данных
mysql_query("SET NAMES utf8");

$res = mysql_query("SELECT * FROM uzer_config WHERE uzer='$login' ORDER BY `id`");
    while($row = mysql_fetch_array($res)){
    $event=$row['event'];
    $event_change = $row['event'];
    $event_confirm = $row['event_confirm'];
    $pass = $row['pass'];
};
if($_pass == $pass && $event==1 && $event_change==1 && $event_confirm==1){
$tableBd="information";

if($lat!=0){
    $sql = "UPDATE `$table_db`.`$tableBd` SET `lat` = '$lat', `lng` = '$lng', `comment` = '$comment'  WHERE `information`.`id` = '$_id';";
    if (!mysql_query($sql,$db))
      {
      die('Error: ' . mysql_error());
      }
    mysql_close($db);
}else{
 $sql = "UPDATE `$table_db`.`$tableBd` SET `comment` = '$comment'  WHERE `information`.`id` = '$_id';";
    if (!mysql_query($sql,$db))
      {
      die('Error: ' . mysql_error());
      }
    mysql_close($db);
}




}else{
mysql_close($db);
echo 'null';
}





?>